package com.ustarlink.live;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.LinearLayout;
import android.widget.TextView;

import java.util.List;

/**
 * Created by cfm on 15-12-23.
 */
public class ChannelsAdapter extends ArrayAdapter<Channel>{
    public ChannelsAdapter(Context ctx, int resourceId, List<Channel> channels) {
        super(ctx, resourceId, channels);
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        LinearLayout row = (LinearLayout)convertView;
        if (null == row){
            LayoutInflater inflater = (LayoutInflater)parent.getContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
            row = (LinearLayout)inflater.inflate(R.layout.channel_list_item, null);
        }
        TextView idTxt = (TextView)row.findViewById(R.id.tv_channel_id);
        TextView nameTxt = (TextView)row.findViewById(R.id.tv_channel_name);

        idTxt.setText(getItem(position).getId());
        nameTxt.setText(getItem(position).getChannelName());

        return row;

    }
}
